<?php

function displaySubMenu($page_code ,$rsSubMenuCats ,$counter)
{
	$str_html = "";
	foreach ($rsSubMenuCats as $rowSubMenuCat)
	{
		$str_html .= "<tr>";
		
		$str_html .= "<td>".h($rowSubMenuCat["id"])."</td>";
		$str_html .= "<td>".h($rowSubMenuCat["code"])."</td>";
		
		$padding = 20*$counter;
		$str_html .= "<td style='padding-left: {$padding}px'>|-- ".h($rowSubMenuCat["name"])."</td>";
		$str_html .= "<td>".h($rowSubMenuCat["last_update"])."</td>";

		$str_html .= "<td style='text-align: center'>";
		if ($rowSubMenuCat['active'] == 1)
			$str_html .= "<a href='".site_url('page/category/active/'.$page_code.'/'.$rowSubMenuCat['id'])."' title='Active' class='btn btn-circle btn-lime'><i class='icon-ok-sign'></i></a>";
		else 
			$str_html .= "<a href='".site_url('page/category/active/'.$page_code.'/'.$rowSubMenuCat['id'])."' title='UnActive' class='btn btn-circle btn-gray'><i class='icon-remove-circle'></i></a>";
		$str_html .= "</td>";
		
		$str_html .= "<td>";
		$str_html .=  "		<a href='javascript:confimDelete(\"".site_url('page/category/delete/'.$page_code.'/'.$rowSubMenuCat['id'])."\");' title='' class='btn btn-small btn-danger'><i class='icon-trash'></i></a>";
		$str_html .=  "		<a class='btn btn-small btn-primary' href='".site_url('page/category/update/'.$page_code).'/'.$rowSubMenuCat['id']."' title='' class='btn btn-small btn-gray'><i class='icon-edit'></i></a>";		
		$str_html .=  "</td>";		
		
		$str_html .= "</tr>";
		
		$str_html .= displaySubMenu($page_code ,$rowSubMenuCat['sub_menus'] ,$counter + 1);
	}
	
	return $str_html;
}

?>

<div class="content">

	<div class="header">
		<div class="page-title">
                    <div>
                        <h1><i class="icon-file-alt"></i>Category : <?php echo h($rowPageConf['name']); ?></h1>
                        <h4><?php echo $page_title .' : ' . h($rowPageConf['name']); ?> !</h4>
                    </div>
        </div>		
	</div>

	<div class="container-fluid">
		<div class="row-fluid">

			<div class="btn-toolbar text-right">
				<a href="<?php echo site_url("page/category/add/{$rowPageConf['code']}"); ?>" class="btn btn-primary"><i class="icon-plus"></i> New Category</a>			
			</div>
			
            <!-- BEGIN Main Content -->
			<div class="row-fluid">
                    <div class="span12">
                        <div class="box">
                            <div class="box-title">
                                <h3>
                                	<i class="icon-table"></i>
                                	<?php echo $page_title .' : '.h($rowPageConf['name']); ?>
                                </h3>
                            </div>
                            <div class="box-content">
                                <table class="table table-striped table-hover fill-head">
                                    <thead>
                                        <tr>
                                            <th width="25px">#</th>
                                            <th width="15%">Code</th>
                                            <th>Name</th>
                                            <th style="width: 150px">Last Update</th>
                                            <th style="width: 100px">Active</th>
                                            <th style="width: 100px">Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    
									<?php echo displaySubMenu($rowPageConf['code'] ,$arrMenuTree ,0); ?>                                        
                                        
                                    </tbody>
                                </table>
                            
                            </div>
                            
                        </div>
                    </div>
			</div>
			<!-- END Main Content -->
                			
			
		</div>
	</div>
</div>


